package com.ethan.springcloud.helloserviceclient;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author daifei
 * @date 2019/3/22
 */
@RestController
@Slf4j
public class HelloController {

    @Autowired
    private RestTemplate restTemplate;


    @Autowired
    private HelloServiceWithFallback helloServiceWithFallback;

    /**
     * 坑点： 使用 服务名调用服务，必须@LoadBalanced 注解
     *
     * @param name
     * @return
     */
    @GetMapping("hello")
    public String hello(String name) {
        return helloServiceWithFallback.hello(name);
    }


}
